package cn.lili.controller.feign;

import cn.lili.modules.promotion.client.MemberCouponClient;
import cn.lili.modules.promotion.service.MemberCouponService;
import cn.lili.modules.promotion.service.MemberCouponSignService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: ftyy
 * @date: 2022-01-13 17:47
 * @description: 会员优惠券实现类
 */
@RestController
@RequiredArgsConstructor
public class MemberCouponFeignController implements MemberCouponClient {

    private final MemberCouponService memberCouponService;

    private final MemberCouponSignService memberCouponSignService;

    @Override
    public void receiveCoupon(String couponId, String memberId, String memberName) {
        memberCouponService.receiveCoupon(couponId, memberId, memberName);
    }

    @Override
    public void used(String memberId, List<String> ids) {
        memberCouponService.used(memberId, ids);
    }

    /**
     * 作废无效的会员优惠券
     *
     * @return 是否操作成功
     */
    @Override
    public boolean expireInvalidMemberCoupon() {
        return memberCouponService.expireInvalidMemberCoupon();
    }

    @Override
    public boolean expireInvalidMemberCoupon(String memberId, String couponId) {
        return memberCouponService.expireInvalidMemberCoupon(memberId, couponId);
    }

    /**
     * 删除作废/过期的会员优惠券
     *
     * @param expirationDay 过期常量，过期后或者使用后一定时间内，删除无效的优惠券，物理删除
     * @return 是否操作成功
     */
    @Override
    public boolean removeInvalidMemberCoupon(int expirationDay) {
        return memberCouponService.removeInvalidMemberCoupon(expirationDay);
    }

    @Override
    public void cleanMemberCouponSign() {
        memberCouponSignService.clean();
    }
    @Override
    public boolean recoveryMemberCoupon(List<String> memberCouponIds) {
        return memberCouponService.recoveryMemberCoupon(memberCouponIds);
    }

    @Override
    public Long getMemberCouponCount(String memberId, String couponId) {
        return memberCouponService.getMemberCouponNum(memberId, couponId);
    }
}
